package com.yq.tanhua.net

import com.yq.tanhua.net.intercept.HeaderInterceptor
import convert.CustomGsonConverterFactory
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.converter.scalars.ScalarsConverterFactory
import retrofit2.create
import java.util.concurrent.TimeUnit


//var baseUrl = "http://192.168.1.6:18080"
//var baseUrl = "http://192.168.51.111:18080"
var baseUrl = "http://139.9.119.166:18080"
private val okHttpClient by lazy {
    OkHttpClient.Builder()
        .addInterceptor(HeaderInterceptor())
        .readTimeout(60,TimeUnit.SECONDS)
        .writeTimeout(60,TimeUnit.SECONDS)
        .build()
}

private val retrofit by lazy {
    Retrofit.Builder()
        .client(okHttpClient)
        .addConverterFactory(CustomGsonConverterFactory.create())
        .baseUrl(baseUrl)
        .build()
}

object TanHuaApiService : TanHuaApi by retrofit.create(TanHuaApi::class.java)


